Repository navigation
Add Cinder quota accounting reads - #1
Conversation
ConnectContext pings and closes the pool when the database does not answer, so a caller that starts during a database outage has no pool at all. The OpenStack database exporter then reports its services as down until it is restarted, even after the database is back. Open does the parsing and pool setup without contacting the server, and ConnectContext becomes Open plus the ping, so existing callers behave as before. The pool connects on first use and reconnects after a lost connection. Tested with go test -race, go vet, gofmt and the integration suite. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Timon Schnell <timon.schnell@btc-it-services.com>
adamhackl
left a comment
There was a problem hiding this comment.
Thanks. The README’s guidance on not adding type-specific and aggregate resources together is helpful. A few things from the observability side:
-
Document that usage is cached accounting
QuotaGetActiveUsage reads quota_usages, which is Cinder’s cached counter, not a count of actual volumes or snapshots. It can drift from reality until it’s reconciled. The Manila PR (#3) states this explicitly, and it would help to say the same here. Anyone alerting on this will otherwise assume it’s ground truth. -
Owner filtering doesn’t match the other quota PRs
These reads return rows with NULL or empty project IDs unfiltered. The Neutron (#4), Octavia (#2) and Manila (#3) PRs all exclude them from usage, and Manila excludes them from limits too. Could Cinder follow the same convention, or document why it differs? -
Parsing resource keys is easy to get wrong
Type-specific keys like gigabytes_fast_ssd encode the volume type name. Every consumer will need to split those keys apart. A naive split on the first _ misreads the aggregate keys backup_gigabytes and per_volume_gigabytes. Keys for deleted volume types also won’t match anything GetVolumeTypes returns. Consider a small exported helper that turns a key into its base resource and volume type, using the known prefixes (volumes_, snapshots_, gigabytes_). At minimum, document the parsing rule. -
Nit: deterministic ordering
Duplicate rows are intentionally kept, but neither query has an ORDER BY. Consumers that collapse duplicates will get whichever row comes last, and that can change between calls. -
Nit: CI conflict
#2 and #4 add the same Python unittest step to ci.yaml. Whichever lands second will conflict.
ca4af2b to
6a67861
Compare
Open adds no dial timeout, so a pool held through a database outage does not fail fast. Say so in the Open doc comment and the README, and move the Open note into its own README paragraph. Signed-off-by: Mohammed Naser <mnaser@vexxhost.com>
Add Open for a pool without the startup ping
6a67861 to
ac0dc8b
Compare
Add three read-only Designate queries for openstack_database_exporter: - ZoneGetAll: non-deleted zones with status and type. - RecordsetCountByZone: recordset count per non-deleted zone, including zones with no recordsets, without reading individual records. - RecordsetGetAllWithStatus: recordsets with the status the Designate API reports (worst child record status in the order ERROR, PENDING, ACTIVE, DELETED; ACTIVE when a recordset has no records). Zone and recordset IDs are returned as dashed UUIDs, matching the API. Splitting the queries lets the exporter skip the per-recordset status query when that metric is disabled. Signed-off-by: Tadas Sutkaitis <tadas.sutkaitis@vexxhost.com>
Add three read-only Cinder quota queries, named after the Cinder DB API
functions they follow, that read every project at once and return raw
rows:
- QuotaGetAllByProject: active project limits from quotas.
- QuotaUsageGetAllByProject: cached in_use and reserved counters from
quota_usages, including projects without limit overrides.
- QuotaClassGetDefaults: limits of the persisted default quota class.
Rows with a NULL or empty project ID are excluded, because Cinder quota
rows belong to Keystone projects. Results are ordered by project,
resource and row ID. Duplicate rows, NULL, zero and -1 limits are
returned as stored. The existing exporter quota queries are unchanged.
Add ParseQuotaResource, which splits per-volume-type keys
("<part>_<volume type name>") using Cinder's known parts and global
resource names, so backup_gigabytes and type names with underscores are
not misread.
Add quota_classes to the Cinder schema fixture, a MariaDB integration
test with a quota fixture, smoke calls in TestCinderQueries, and API.md
documentation.
Co-authored-by: David Hulick <dave.hulick@gmail.com>
Signed-off-by: David Hulick <dave.hulick@gmail.com>
Signed-off-by: Jeremy Lee <jeremy.lee1664@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ac0dc8b to
61d4612
Compare
Add independent Cinder quota accounting reads
Summary
Add independent, read-only Cinder quota queries for retrieving active project limits, quota usage, and default-class limits without requiring callers to reconstruct these values from existing joined queries.
Motivation
The existing Cinder quota queries are useful for specific lookups but have limitations for complete quota accounting:
QuotaGetAllWithUsagequery omits projects that have usage records but no explicit quota override.The new queries expose the underlying records independently so consumers can perform aggregation and effective-limit resolution according to their requirements.
Changes
QuotaGetActiveLimits,QuotaGetActiveUsage, andQuotaGetDefaultClassLimits.QuotaRepositoryfacade for quota reads and current volume-type retrieval.quota_classes.Compatibility
The changes are additive. Existing Cinder queries, exported signatures, volume filters, and attachment behavior are preserved.
The
quota_classesaddition is part of the embedded schema fixture used for tests and code generation; it is not a production database migration.Validation
sqlc v1.30.0.go vetand formatting checks passed.The Python/SQLite tests provide fast, Docker-free checks of selected SQL semantics. They are complementary to the native MariaDB tests, not a substitute for them. Because SQLite differs from MariaDB in schema syntax and comparison behavior, the native integration suite remains the database-compatibility check.
We're open to adjustments to the testing approach or public API organization if maintainers prefer different conventions.